Today I'm going to introduce a wave loop so that things can happen periodically.
And also I want to introduce module scripts, which are scripts that can be called from other scripts.
So we're going to use them as a code library, which is really, really useful.
So let's go over here to server script service, open it up, see what we got in there.
Well, we do have this spanner in here.
That's a regular script.
I'm going to hit the plus sign and I'm going to add a module script, write, module script.
Make sure you get that right, because a regular script is not going to work if you're trying it.
All right, this module script, I'm going to call session utils.
It's going to be a library of functions.
Whoops.
But I'm going to call from another script now.
Session utils.
Let me make this bigger so you can see it.
Is going to have a table inside it when we require our session utils in another script or include it.
If you're more familiar with that terminology, we're going to get a table returned.
It's going to have our functions stored in the table.
Pretty cool.
I'm going to call this table utils and if you change the name here, you have to change the name down
here.
It does not have to match this one obviously because I have session utils.
Right.
And let's go and make a function that we're going to store in this utils table that we can use someplace
else.
So I'm going to say function not local because it's not local to my script, utils, colon, start wav
and then just go put a little print statement in here, print wav starting if I could spell it right.
There we go.
It's pretty simple to start off.
Now let's go to server script service on a close Z spanner so it gets out of the way, but in server
script servers are going to hit the plus.
Now I'm going to get a regular script right, or a server script, we call it.
It just says script, but it runs on the server.
I'm going to call this wave loop.
All right.
And in wave loop, I want to require my session utils.
I want to import it or include it.
Whatever programming language you come from.
Or maybe not at all.
Right.
So they use require in node.js.
So you like that if you want to do Node.js.
All right.
So I'm going to require and I need to find it.
So we have this top level game object in there.
We have server script service, that's this right here.
And then I could do this dot session, Utils Walla, I got my utils.
This is going to be the table that's going to have all my functions in there.
So let me do a little loop here while true do and then I'll do a little weight statement.
You don't want to crash your machine and we'll go utils colon start wav.
Let's see what we got.
We should see this print statement firing once a second, so we'll hit the play button.
Let's go to The View so we can take a look at our output window.
And there we go.
Waves started so you could see that it's printing over and over and over again.
Oh, look at that.
We had our eruption.
We should put that in the wave.
That would be pretty cool.